package org.real.guetshop.config;

import lombok.extern.slf4j.Slf4j;
import org.real.guetshop.propertis.AliOssProperties;
import org.real.guetshop.utils.AliOssUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类，用于生成oss对象
 */
@Slf4j
@Configuration
public class OssConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil aliossUtil(AliOssProperties aliOssProperties){
        log.info("开始创建阿里云上传文件对象：{}", aliOssProperties);
        return new AliOssUtil(
                aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName()
                );
    }
}
